<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>功能分配</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" type="text/css"
	href="../themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="../themes/icon.css">
<link rel="stylesheet" type="text/css" href="../themes/color.css">
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script src="../bootstrap/js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../js/easyui-lang-zh_CN.js"></script>

<script type="text/javascript">
    function pageInit(page){
    	var url = "${ctx}/searchFunc";
		var params = {};
		params.rname = $("input[name='rname']").val();
		params.page = page;
		params.pagesize = "10";
		$.ajax({
					
					url : url,
					dataType : 'json',
					data : params,
					success : function(data) {
						var funcarry = data.funcarray;
						if (funcarry && funcarry.length > 0) {
							var html = "";
							for (o in funcarry) {
								if (funcarry[o].isselect == 1) {
									html += "<input type=\"checkbox\" value=\""+funcarry[o].id+"\" checked=\"checked\" name=\"funcs\"/>";
								} else {
									html += "<input type=\"checkbox\" value=\""+funcarry[o].id+"\" name=\"funcs\"/>";
								}
								html += funcarry[o].text;
							}
							$("#showData").html(html);
						}
						    var pageHtml=data.pageHtml;
							$("#pageHtml").html(pageHtml);
					}
				});
    }
	$(function() {
		$("#ss").click(function() {
			pageInit(1);
		});
		$(document).on("click", "#addordel", function() {
			var chk_value = [];

			$("input[name='funcs']:checked").each(function() {
				chk_value.push($(this).val());
			});
			var a = chk_value.join(",");
			// alert(a);
			var url = "${ctx}/updatefunc";
			var params = {};
			params.fname = a;
			params.rname = $("input[name='rname']").val();
			//params.rname='11'
			$.ajax({
				url : url,
				datatype : 'json',
				data : params,
				success : function(data) {
					alert("更新成功");
				}
			})
		})

	});
</script>
</head>

<body>

	<div style="text-align: center;">
		<p>功能分配</p>
		<form action="searchFunc">
			<div class="input-group">
				<input type="text" class="form-control" name="rname" /> <span
					class="input-group-btn"> <input id="ss"
					class="btn btn-default" type="button" value="搜索" />
				</span>
			</div>
		</form>

		<div style="margin: 20px 0;"></div>
		<div  class="easyui-panel" >
				<div id="showData" ></div>
				
				<div id="pageHtml"></div>
				<input id="addordel" class="btn btn-default" type="button"
					value="提交" />
		</div>
	</div>
</body>
</html>